//Sunday, November 15 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class ProductOfDigits
{
public:
	int smallestNumber(int N)
	{
		if(N == 1) return 1;
		int ret = 0;
		while(N != 1)
		{
			int i;
			for(i=9; i>1; i--)
			{
				if(N%i == 0)
				{
					N /= i;
					ret ++;
					break;
				}
			}
			if(i == 1) return -1;
		}
		return ret;
	}
};
